// PGLEngine.h : Declaration of the CPGLEngine

#ifndef __PGLENGINE_H_
#define __PGLENGINE_H_

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CPGLEngine
class ATL_NO_VTABLE CPGLEngine : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CPGLEngine, &CLSID_PGLEngine>,
	public ISupportErrorInfo,
	public IDispatchImpl<IPGLEngine, &IID_IPGLEngine, &LIBID_PGLSERVERLib>
{
protected:
	CPGLScript m_script;
	gfxinterface::CGDIpInitializer m_GDIpInitializer;

protected:
	static CPGLVectorFPtr SafeArrayToCPGLData(SAFEARRAY* sa);

public:
	CPGLEngine()
	: m_GDIpInitializer(true)
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_PGLENGINE)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CPGLEngine)
	COM_INTERFACE_ENTRY(IPGLEngine)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IPGLEngine
public:
	STDMETHOD(LoadCSVFile)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrFileName, /*[out, retval]*/ VARIANT_BOOL __RPC_FAR* pbResult);
	STDMETHOD(DoModalRegion)(/*[in]*/ long lRegionID, /*[out, retval]*/ int __RPC_FAR* iResult);
	STDMETHOD(Layout)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrLayout, /*[out,retval]*/ long __RPC_FAR* plRegionID);
	STDMETHOD(Image)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrFileName, /*[in]*/ BSTR bstrFormat, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(PlotVer)(/*[in]*/ long lRegionID, /*[in]*/ double dX, /*[in]*/ BSTR bstrFlags,/*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(PlotHor)(/*[in]*/ long lRegionID, /*[in]*/ double dY, /*[in]*/ BSTR bstrFlags, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(Grid)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrState, /*[out, retval]*/long __RPC_FAR* plObjectID);
	STDMETHOD(AutoZoom)(/*[in]*/ BSTR bstrState);
	STDMETHOD(RenderToStream)(/*[in]*/ long lRegionID, /*[in]*/ IUnknown* pStream, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ VARIANT_BOOL __RPC_FAR* pbSuccess);
	STDMETHOD(RenderToResponse)(/*[in]*/ long lRegionID, /*[in]*/ IUnknown* pResponse, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ VARIANT_BOOL __RPC_FAR* pbSuccess);
	STDMETHOD(OutOfChild)();
	STDMETHOD(Legend)(/*[in]*/ long lRegionID, /*[out, retval]*/ long* lLegendID);
	STDMETHOD(RenderToFile)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrFileName, /*[in]*/ BSTR bstrFormat, /*[out, retval]*/ VARIANT_BOOL __RPC_FAR* pbSuccess);
	STDMETHOD(LoadXML)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrFileName, /*[out,retval]*/ VARIANT_BOOL __RPC_FAR*pbSuccess );
	STDMETHOD(SaveXML)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrFileName, /*[in]*/ VARIANT_BOOL bZipping, /*[out,retval]*/ short __RPC_FAR* pbSuccess);
	STDMETHOD(SetCR)(/*[in]*/ long lRegionID, /*[out,retval]*/ VARIANT_BOOL __RPC_FAR* pbSuccess);
	STDMETHOD(GetChildrenSize)(/*[in]*/ long lRegionID, /*[out, retval]*/ long __RPC_FAR* plChildrenSize);
	STDMETHOD(GetChild)(/*[in]*/ long lParentID, /*[in]*/ long lIndex, /*[out, retval]*/ long __RPC_FAR* plChildID);
	STDMETHOD(GetObjectsSize)(/*[in]*/ long lRegionID, /*[out, retval]*/ long __RPC_FAR* plObjectsSize);
	STDMETHOD(GetObject)(/*[in]*/ long lRegionID, /*[in]*/ long lIndex, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(CloseAllFigures)();
	STDMETHOD(CloseAllRegions)();
	STDMETHOD(CloseFigure)(/*[in]*/ long lFigID);
	STDMETHOD(CloseRegion)(/*[in]*/ long lRegionID);
	STDMETHOD(Set)(/*[in]*/ long lObjectID, /*[in]*/ BSTR bstrPropAndValues);
	STDMETHOD(Get)(/*[in]*/ long lObjectID, /*[in]*/ BSTR bstrProp, /*[out, retval]*/ BSTR __RPC_FAR* pbstrValue);
	STDMETHOD(GetHelp)(/*[in]*/ long lObjectID, /*[out,retval]*/ BSTR __RPC_FAR* pbstrHelp);
	STDMETHOD(GetParent)(/*[in]*/ long lObjectID, /*[out, retval]*/ long __RPC_FAR* plParentID);
	STDMETHOD(Divide)(/*[in]*/ long lRegionID, /*[in]*/ long lnRows, /*[in]*/ long lnCols, /*[out,retval]*/ long __RPC_FAR* plRegionID );
	STDMETHOD(GetCR)(/*[out, retval]*/ long* plRegionID);
	STDMETHOD(Title)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrLabel, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(LeftLabel)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrLabel, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(RightLabel)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrLabel, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(BottomLabel)(/*[in]*/ long lRegionID, /*[in]*/ BSTR bstrLabel, /*[out, retval]*/ long __RPC_FAR* plObjectID);
	STDMETHOD(Region)(/*[out, retval]*/long __RPC_FAR* plRegionID);
	STDMETHOD(PlotLOD)(/*[in]*/ long lRegionID, /*[in]*/ SAFEARRAY* saX, /*[in]*/ SAFEARRAY* saY, /*[in]*/float fCompRatio, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(PlotLODY)(/*[in]*/ long lRegionID, /*[in]*/ double dX0, /*[in]*/ double dXStep, /*[in]*/ SAFEARRAY* saY, /*[in]*/float fCompRatio, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(Plot)(/*[in]*/ long lRegionID, /*[in]*/ SAFEARRAY* saX, /*[in]*/ SAFEARRAY* saY, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(PlotY)(/*[in]*/ long lRegionID, /*[in]*/ double dX0, /*[in]*/ double dXStep, /*[in]*/ SAFEARRAY* saY, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(PlotFcn)(/*[in]*/ long lRegionID, /*[in]*/ SAFEARRAY* saX, /*[in]*/ BSTR bstrFcnX, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(PlotFcnY)(/*[in]*/ long lRegionID, long nPoints, /*[in]*/ double dX0, /*[in]*/ double dXStep, /*[in]*/ BSTR bstrFcnX, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(Histogram)(/*[in]*/ long lRegionID, /*[in]*/ SAFEARRAY* saY, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(Scatter)(/*[in]*/ long lRegionID, /*[in]*/ SAFEARRAY* saX, /*[in]*/ SAFEARRAY* saY, /*[in]*/ SAFEARRAY* saScatter, /*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(Stock)(/*[in]*/ long lRegionID, /*[in]*/ double dX0, /*[in]*/ double dXStep,/*[in]*/ SAFEARRAY* saOpen, /*[in]*/ SAFEARRAY* saHigh, /*[in]*/ SAFEARRAY* saLow, /*[in]*/ SAFEARRAY* saClose,/*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(CandleStick)(/*[in]*/ long lRegionID, /*[in]*/ double dX0, /*[in]*/ double dXStep,/*[in]*/ SAFEARRAY* saOpen, /*[in]*/ SAFEARRAY* saHigh, /*[in]*/ SAFEARRAY* saLow, /*[in]*/ SAFEARRAY* saClose,/*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(ErrorBar)(/*[in]*/ long lRegionID, /*[in]*/ SAFEARRAY* saX, /*[in]*/ SAFEARRAY* saY, /*[in]*/ SAFEARRAY* saErroUp, /*[in]*/ SAFEARRAY* saErrorDown,/*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(ErrorBarY)(/*[in]*/ long lRegionID, /*[in]*/ double dX0, /*[in]*/ double dXStep, /*[in]*/ SAFEARRAY* saY, /*[in]*/ SAFEARRAY* saErroUp, /*[in]*/ SAFEARRAY* saErrorDown,/*[in]*/ BSTR bstrFormat, /*[out,retval]*/ long __RPC_FAR* lObjectID);
	STDMETHOD(Figure)(/*[out, retval]*/ long __RPC_FAR * lpDlgID);
};

#endif //__PGLENGINE_H_
